//
//  HeaderSaleView.m
//  Car
//
//  Created by lanou on 15/9/19.
//  Copyright (c) 2015年 朱鸿儒. All rights reserved.
//

#import "HeaderSaleView.h"

@implementation HeaderSaleView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self) {
        self.isSaling = YES;
        self = [super initWithFrame:frame];
        self.title = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 180, 40)];
        [self addSubview:self.title];
        
        UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
        button.frame = CGRectMake(180, 0, 120, 40);
        [self addSubview:button];
        [button addTarget:self action:@selector(buttonClick:) forControlEvents:(UIControlEventTouchUpInside)];
        [button setTitle:@"显示全部车型" forState:(UIControlStateNormal)];
        button.titleLabel.textColor = [UIColor blueColor];
        self.backgroundColor = [UIColor lightGrayColor];
    }
    return self;
}
- (void)buttonClick:(UIButton *)button{
    self.isSaling = !self.isSaling;
    if (self.isSaling == YES) {
        [button setTitle:@"显示全部车型" forState:(UIControlStateNormal)];
    }
    else
        [button setTitle:@"显示在售车型" forState:(UIControlStateNormal)];
}

@end
